<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='fxsdj'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">

    <div class="layui-card">
        <div class="layui-field-box layui-form">

            <table class="layui-table" lay-size="sm">
                <thead>
                <tr>
                    <th><fmt:message key='djtp'/></th>
                    <th><fmt:message key='djmc'/></th>
                    <th><fmt:message key='yjyjbl'/></th>
                    <th><fmt:message key='ejyjbl'/></th>
                    <th><fmt:message key='sqtj'/></th>
                    <th><fmt:message key='xjfxssl'/></th>
                    <th><fmt:message key='zsfxssl'/></th>
                    <th><fmt:message key='xxhys'/></th>
                    <th><fmt:message key='xxhydds'/></th>
                    <th><fmt:message key='xxhyddje'/></th>
                    <th><fmt:message key='cjdds'/></th>
                    <th><fmt:message key='cjje'/></th>
                    <th><fmt:message key='cz'/></th>
                </tr>
                </thead>
                <c:forEach items="${list}" var="item" varStatus="status">
                    <tr>
                        <td>
                            <c:if test="${not empty item.image}">
                                <img src="${store_domain}/uploads/${item.image}" class="preview">
                            </c:if>
                        </td>
                        <td>${item.name}</td>
                        <td>
                            <c:if test="${item.firstLevelScale != null}">
                                <fmt:formatNumber type="percent" value="${item.firstLevelScale}" maxFractionDigits="2"/>
                            </c:if>
                        </td>
                        <td>
                            <c:if test="${item.secondLevelScale != null}">
                                <fmt:formatNumber type="percent" value="${item.secondLevelScale}"
                                                  maxFractionDigits="2"/>
                            </c:if>
                        </td>
                        <td>
                            <c:if test="${item.applyType eq 1}"><fmt:message key='mfjr'/></c:if>
                            <c:if test="${item.applyType eq 2}"><fmt:message key='gmzdsp'/></c:if>
                        </td>
                        <td>
                            <c:if test="${item.enableSubDistributorNum}">
                                ${item.subDistributorNum}~${item.subDistributorMaxNum}
                            </c:if>
                        </td>
                        <td>
                            <c:if test="${item.enableChildDistributorNum != null}">
                                ${item.childDistributorNum}~${item.childDistributorMaxNum}
                            </c:if>
                        </td>
                        <td>
                            <c:if test="${item.enableSubMemberNum != null}">
                                ${item.subMemberNum}~${item.subMemberMaxNum}
                            </c:if>
                        </td>
                        <td>
                            <c:if test="${item.enableSubMemberOrderNum != null}">
                                ${item.subMemberOrderNum}~${item.subMemberOrderMaxNum}
                            </c:if>
                        </td>
                        <td>
                            <c:if test="${item.enableSubMemberOrderMoney != null}">
                                ${item.subMemberOrderMoney}~${item.subMemberOrderMaxMoney}
                            </c:if>
                        </td>
                        <td>
                            <c:if test="${item.enableOrderNum != null}">
                                ${item.orderNum}~${item.orderMaxNum}
                            </c:if>
                        </td>
                        <td>
                            <c:if test="${item.enableOrderMoney != null}">
                                ${item.orderMoney}~${item.orderMaxMoney}
                            </c:if>
                        </td>
                        <td>
                            <div class="layui-btn-container">
                                <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs modify"
                                   data-level="${item.level}"><fmt:message key='bj'/></a>
                                <c:if test="${item.id != null}">
                                    <a href="javascript:void(0);" data-id="${item.id}"
                                       class="layui-btn layui-btn-danger layui-btn-xs remove"
                                       data-level="${item.level}"><fmt:message key='sc'/></a>
                                </c:if>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>

</div>

<script>

    layui.use("layer", function () {

        var layer = layui.layer;

        //编辑分销商等级
        $(".modify").click(function () {
            var level = $(this).attr("data-level");
            layer.open({
                type: 2,
                title: "<fmt:message key='fxsdjsz'/>",
                content: "${web_domain}/distributorLevel/modify?level=" + level,
                area: ["90%", "90%"],
                btn: ["<fmt:message key='qd'/>", "<fmt:message key='qx'/>"],
                yes: function (index, layero) {
                    layero.find('iframe').contents().find("#submit").click();
                }
            });
        });

        //编辑分销商等级
        $(".remove").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrscm?'/>", function () {
                feijin.delete({
                    url: "${web_domain}/distributorLevel/remove?id=" + id,
                    data: {}
                });
            })
        });

    });
</script>
</body>
</fmt:bundle>
</html>
